package com.syg.boot.mq.cmq.consumer;

import com.syg.boot.mq.common.MQProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author qg
 * @version 1.0
 */
public class CmqSimpleMessageConsumer {
    private static final Logger log = LoggerFactory.getLogger(CmqSimpleMessageConsumer.class);
    private MQProperties cmqProperties;

    public CmqSimpleMessageConsumer(MQProperties cmqProperties) {
        this.cmqProperties = cmqProperties;
    }

    public void setCmqProperties(MQProperties cmqProperties) {
        this.cmqProperties = cmqProperties;
    }

    public MQProperties getCmqProperties() {
        return this.cmqProperties;
    }


    // public <T> ZsfReveiceResult<T> receiveMsg(String queueName, int pollingWaitingSeconds, Class<T> clazz) {
    //     ZsfReveiceResult<T> zsfResult = new ZsfReveiceResult();
    //     Consumer consumer = new Consumer();
    //
    //     try {
    //         consumer.setNameServerAddress(this.cmqProperties.getAddress());
    //         consumer.setSecretId(this.cmqProperties.getSecretId());
    //         consumer.setSecretKey(this.cmqProperties.getSecretKey());
    //         consumer.setSignMethod(this.cmqProperties.getSignMethod());
    //         consumer.setRetryTimesWhenSendFailed(this.cmqProperties.getRetryTimesWhenSendFailed());
    //         consumer.setRequestTimeoutMS(this.cmqProperties.getRequestTimeoutMS());
    //         consumer.setBatchPullNumber(16);
    //         consumer.setPollingWaitSeconds(6);
    //         consumer.start();
    //         ReceiveResult result = consumer.receiveMsg(queueName, pollingWaitingSeconds);
    //         log.info("原始结果：" + JsonUtils.objectToJson(result));
    //         if (result == null) {
    //             ZsfReveiceResult var7 = zsfResult;
    //             return var7;
    //         }
    //
    //         zsfResult = new ZsfReveiceResult(result);
    //         log.info("转换结果：" + JsonUtils.objectToJson(zsfResult));
    //         if (zsfResult.isStatus()) {
    //             log.info("1111111111111");
    //             consumer.deleteMsg(queueName, result.getMessage().getReceiptHandle());
    //         }
    //     } catch (Exception var11) {
    //         log.error("", var11);
    //     } finally {
    //         consumer.shutdown();
    //     }
    //
    //     return zsfResult;
    // }
}
